/* *****************************************************************************
 * JFab (http://code.google.com/p/jfab)
 * Copyright (c) 2011 JFab.org
 * Admin jfab@jeffreythompson.net
 *
 * See the file "LICENSE.txt" for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * *****************************************************************************/

package org.jfab.core.collection;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/**
 * Provides base functionality for a code generator list.
 * 
 * @param <T> Type.
 */
public abstract class CGList<T> implements List<T>
{
    /** List. */
    private final List<T> _list;

    /**
     * Construct this object with the given parameter.
     * 
     * @param list List.
     */
    protected CGList(final List<T> list)
    {
        _list = list;
    }

    @Override
    public void add(final int index, final T element)
    {
        _list.add(index, element);
    }

    @Override
    public boolean add(final T e)
    {
        return _list.add(e);
    }

    @Override
    public boolean addAll(final Collection<? extends T> c)
    {
        return _list.addAll(c);
    }

    @Override
    public boolean addAll(final int index, final Collection<? extends T> c)
    {
        return _list.addAll(index, c);
    }

    @Override
    public void clear()
    {
        _list.clear();
    }

    @Override
    public boolean contains(final Object o)
    {
        return _list.contains(o);
    }

    @Override
    public boolean containsAll(final Collection<?> c)
    {
        return _list.containsAll(c);
    }

    @Override
    public boolean equals(final Object o)
    {
        return _list.equals(o);
    }

    @Override
    public T get(final int index)
    {
        return _list.get(index);
    }

    @Override
    public int hashCode()
    {
        return _list.hashCode();
    }

    @Override
    public int indexOf(final Object o)
    {
        return _list.indexOf(o);
    }

    @Override
    public boolean isEmpty()
    {
        return _list.isEmpty();
    }

    @Override
    public Iterator<T> iterator()
    {
        return _list.iterator();
    }

    @Override
    public int lastIndexOf(final Object o)
    {
        return _list.lastIndexOf(o);
    }

    @Override
    public ListIterator<T> listIterator()
    {
        return _list.listIterator();
    }

    @Override
    public ListIterator<T> listIterator(final int index)
    {
        return _list.listIterator(index);
    }

    @Override
    public T remove(final int index)
    {
        return _list.remove(index);
    }

    @Override
    public boolean remove(final Object o)
    {
        return _list.remove(o);
    }

    @Override
    public boolean removeAll(final Collection<?> c)
    {
        return _list.removeAll(c);
    }

    @Override
    public boolean retainAll(final Collection<?> c)
    {
        return _list.retainAll(c);
    }

    @Override
    public T set(final int index, final T element)
    {
        return _list.set(index, element);
    }

    @Override
    public int size()
    {
        return _list.size();
    }

    @Override
    public List<T> subList(final int fromIndex, final int toIndex)
    {
        return _list.subList(fromIndex, toIndex);
    }

    @Override
    public Object[] toArray()
    {
        return _list.toArray();
    }

    @Override
    public <U> U[] toArray(final U[] a)
    {
        return _list.toArray(a);
    }

    /**
     * @return the list
     */
    protected List<T> getList()
    {
        return _list;
    }
}
